package com.conero.yangsu.controller.system;

import com.conero.yangsu.lib.AdminSecurity;
import com.conero.yangsu.lib.FeedbackData;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

// 后台登录检测
@Component
public class SystemLoginValidate implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Object admin = AdminSecurity.getAdminInfo(request.getSession());
        if(null == admin){
            response.sendRedirect("/system/login/overdue");
            return false;
        }
        return HandlerInterceptor.super.preHandle(request, response, handler);
    }
}
